using System;
using EtlDemo.Rhino.JobCounts.Aggregates;
using EtlDemo.Rhino.JobCounts.Inputs;
using EtlDemo.Rhino.JobCounts.Joins;
using EtlDemo.Rhino.JobCounts.Outputs;
using Rhino.Etl.Core;

namespace EtlDemo.Rhino.JobCounts
{
    public class JobCountProcess : EtlProcess
    {
        readonly Staging staging = new Staging();

        protected override void Initialize()
        {
            Register(new JoinLegacyCountsWithAffiliates()
                         .Left(new JobCountsByZipCodeInput())
                         .Right(new AffiliateZipCodesInput()));

            Register(new JobCounter());

            Register(new DefaultAffiliateRow());

//            Register(new RowVisualizer(Console.Out));

            Register(new BulkInsertToStaging());

            staging.CreateStagingTable();
        }

        protected override void PostProcessing()
        {
            staging.UpsertFromStagingTable();
        }

        public static void Test()
        {
            new JobCountProcess().Execute();
        }
    }
}